using System;

namespace _RobotInspection.Models
{
    /// <summary>
    /// 业务异常类
    /// </summary>
    public class BusinessException : Exception
    {
        /// <summary>
        /// 错误代码
        /// </summary>
        public int Code { get; }

        /// <summary>
        /// 初始化 BusinessServiceException 类的新实例
        /// </summary>
        /// <param name="message">错误信息</param>
        public BusinessException(string message) : base(message)
        {
            Code = 500;
        }

        /// <summary>
        /// 初始化 BusinessServiceException 类的新实例
        /// </summary>
        /// <param name="code">错误代码</param>
        /// <param name="message">错误信息</param>
        public BusinessException(int code, string message) : base(message)
        {
            Code = code;
        }

        /// <summary>
        /// 初始化 BusinessServiceException 类的新实例
        /// </summary>
        /// <param name="message">错误信息</param>
        /// <param name="innerException">内部异常</param>
        public BusinessException(string message, Exception innerException) : base(message, innerException)
        {
            Code = 500;
        }

        /// <summary>
        /// 初始化 BusinessServiceException 类的新实例
        /// </summary>
        /// <param name="code">错误代码</param>
        /// <param name="message">错误信息</param>
        /// <param name="innerException">内部异常</param>
        public BusinessException(int code, string message, Exception innerException) : base(message, innerException)
        {
            Code = code;
        }
    }
}